﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar;

namespace PlanningGIS.Win.Controls
{
    /// <summary>
    /// 文本框控件
    /// </summary>
    public partial class FrmText : Office2007Form
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        public FrmText()
        {
            InitializeComponent();
            AllowNull = false;
        }

        /// <summary>
        /// 加载窗体
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FrmText_Load(object sender, EventArgs e)
        {

        }

        /// <summary>
        /// 获取或设置标题信息
        /// </summary>
        public string Title
        {
            get { return this.Text; }
            set { this.Text = value; }
        }

        /// <summary>
        /// 提示消息
        /// </summary>
        public string ToolTip
        {
            get { return lblTip.Text; }
            set { lblTip.Text = value; }
        }

        /// <summary>
        /// 输入的值
        /// </summary>
        public string Value
        {
            get { return txtValue.Text.Trim(); }
            set { txtValue.Text = value; }
        }

        /// <summary>
        /// 是否允许为空
        /// </summary>
        public bool AllowNull { get; set; }

        /// <summary>
        /// 确定
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (!AllowNull)
            {
                if (string.IsNullOrWhiteSpace(txtValue.Text))
                {
                    MsgHelper.ShowErrorMsgbox("不能为空，请重新输入");
                    return;
                }               
            }
            this.DialogResult = System.Windows.Forms.DialogResult.OK;
            this.Close();
        }

        /// <summary>
        /// 取消
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            this.Close();
        }

        
    }
}
